* other data


use "$Endline_dtRaw/other/datafda_1218.dta", clear

label drop _all

replace data3_dia = . if data3_dia==99
replace data3_mes = . if data3_mes==99

rename data1_dia date1
rename data2_dia date2
rename data3_dia date3

rename data1_mes month1
rename data2_mes month2
rename data3_mes month3

lab var school_id 	"ID school"

lab var date1 		"Day of first visit"
lab var month1 		"Month of first visit"
lab var date2 		"Day of second visit"
lab var month2 		"Month of second visit"
lab var date3 		"Day of third visit"
lab var month3 		"Month of third visit"

lab var supervisor_name "Supervisor name"
lab var supervisor_id "Supervisor ID"

drop fim

#delimit ;
;
label define enum
1	"Antonio Lopes Miguel Rocha"
2	"Augusta Júlio Miranda"
3	"César Zau Joaquim Morais Mendes"
4	"Edesdeth Abrantes Fonseca"
5	"Fernando Portugal Leonardo"
6	"Filipe Quissana Cariengue"
7	"Herlander Mauro Lemos Lima"
8	"Manuel Aguinaldo Barroso Moreira Francisco"
9	"Albertina de Oliveira Armando"
10	"Augusto Viana Kupinga"
11	"Beatriz Laurinda Teixeira da Costa"
12	"Carlos da Fonseca Ricardo "
13	"Carolina Germano da Silva"
14	"Felizarda Luis Avelino"
15	"Hermínia Caetano Kalolo"
16	"Ilídio Duarte Reis Cardoso"
17	"Isabel Marcolino Lisboa"
18	"João Monteiro Bimbe"
19	"José Alberto Nungulo Kamucunja"
20	"Manuel Pinheiro Inacio Ernesto"
21	"Marimilia Francisco Fernando"
22	"José Bambi Kandjeke"
23	"Samora Paulo José Ganga"
24	"Victória Maneco Tavares"
25	"Adelaide Fernando Miguens"
26	"Adelaide Marcelina da Cruz Zeferino"
27	"Adilson Fragoso Pascoal Inácio Filipe"
28	"Amaro Alberto Chipa"
29	"Ana Paula Silvestre Ventura"
30	"Antonio Calei Pedro da Silva"
31	"António Manuel da Silva"
32	"Bernardo Miguêns Gimbo"
33	"Bernardo Sungo Manuel Zau"
34	"Bráulio Eanes Gabriel Alberto"
35	"Bruno José Fernando Viegas"
36	"Carvalinho António Correia"
37	"Cirineu Jr. Jorge"
38	"Domingos Guimarães Sumano"
39	"Elvino António Sobral Salomão"
40	"Etelvina Albertina Francisco Teixeira"
41	"Helder Silvestre Lino Tomé Pinto"
42	"Joana Pinto Soma"
43	"Jonas Frederico Albino Rangel"
44	"José Catraio António"
45	"José Luciano Januário"
46	"José Maria Sumano Delgado"
47	"José Pinto Fançony"
48	"Magalhães Salissinga Gomes"
49	"Maria de Fátima Paulo Feliciano"
50	"Mariza Fernando Manuel Vales"
51	"Monteiro Bastos"
52	"Nilton Januário Valentim"
53	"Sara Claúdio Vidro Aguiar Maneco"
54	"Telma da Conceição Mweleyavo António"
55	"Teresa Aguiar da Costa"
56	"Teresa Kizua Kassucada"
57	"Bruno Avelino Segunda"
58	"Inocêncio Mário Cupenala"
59	"Sabino Jorge Bira"
;
label define month
     6 "June"
     7 "July"
     8 "August"
     9 "September"
    10 "October"
    11 "November"
    12 "December"
;
label define dummy
     1 "yes"
     0 "no"
;
#delimit cr

lab val supervisor_id enum
lab val month1 month2 month3 month

*****

destring test_por_01 test_por_02 test_por_03 test_por_04 test_por_05 test_por_06 test_por_07 test_por_08 test_por_09 test_por_10 test_por_11 test_por_12 test_por_13 test_por_14 test_por_15 test_por_16 test_por_17 test_por_18 test_por_19 test_por_20 test_por_21 test_por_22 test_por_23 test_por_24 test_por_25 test_por_26 test_por_27 test_por_28 test_por_29 test_por_30 test_por_31 test_por_32 test_mat_01 test_mat_02 test_mat_03 test_mat_04 test_mat_05 test_mat_06 test_mat_07 test_mat_08 test_mat_09 test_mat_10 test_mat_11 test_mat_12 test_mat_13 test_mat_14 test_mat_15 test_mat_16 test_mat_17 test_mat_18 test_mat_19 test_mat_20 test_mat_21 test_mat_22 test_mat_23 test_mat_24 test_mat_25 test_mat_26 test_mat_27 test_mat_28 test_mat_29 test_mat_30 test_mat_31 test_mat_32 pres_teacher1_01 pres_teacher1_02 pres_teacher1_03 pres_teacher1_04 pres_teacher1_05 pres_teacher1_06 pres_teacher1_07 pres_teacher1_08 pres_teacher1_09 pres_teacher1_10 pres_teacher1_11 pres_teacher1_12 pres_teacher1_13 pres_teacher1_14 pres_teacher1_15 pres_teacher1_16 pres_teacher1_17 pres_teacher1_18 pres_teacher1_19 pres_teacher1_20 pres_teacher1_21 pres_teacher1_22 pres_teacher1_23 pres_teacher1_24 pres_teacher1_25 pres_teacher1_26 pres_teacher1_27 pres_teacher1_28 pres_teacher1_29 pres_teacher1_30 pres_teacher1_31 pres_teacher1_32 pres_teacher1_33 pres_teacher1_34 pres_teacher1_35 pres_teacher1_36 pres_teacher1_37 pres_teacher1_38 pres_teacher1_39 pres_teacher1_40 pres_teacher1_41 pres_teacher1_42 pres_teacher1_43 pres_teacher1_44 pres_teacher1_45 pres_teacher1_46 pres_teacher1_47 pres_teacher1_48 entre_teacher1_01 entre_teacher1_02 entre_teacher1_03 entre_teacher1_04 entre_teacher1_05 entre_teacher1_06 entre_teacher1_07 entre_teacher1_08 entre_teacher1_09 entre_teacher1_10 entre_teacher1_11 entre_teacher1_12 entre_teacher1_13 entre_teacher1_14 entre_teacher1_15 entre_teacher1_16 entre_teacher1_17 entre_teacher1_18 entre_teacher1_19 entre_teacher1_20 entre_teacher1_21 entre_teacher1_22 entre_teacher1_23 entre_teacher1_24 entre_teacher1_25 entre_teacher1_26 entre_teacher1_27 entre_teacher1_28 entre_teacher1_29 entre_teacher1_30 entre_teacher1_31 entre_teacher1_32 entre_teacher1_33 entre_teacher1_34 entre_teacher1_35 entre_teacher1_36 entre_teacher1_37 entre_teacher1_38 entre_teacher1_39 entre_teacher1_40 entre_teacher1_41 entre_teacher1_42 entre_teacher1_43 entre_teacher1_44 entre_teacher1_45 entre_teacher1_46 entre_teacher1_47 entre_teacher1_48 pres_teacher2_01 pres_teacher2_02 pres_teacher2_03 pres_teacher2_04 pres_teacher2_05 pres_teacher2_06 pres_teacher2_07 pres_teacher2_08 pres_teacher2_09 pres_teacher2_10 pres_teacher2_11 pres_teacher2_12 pres_teacher2_13 pres_teacher2_14 pres_teacher2_15 pres_teacher2_16 pres_teacher2_17 pres_teacher2_18 pres_teacher2_19 pres_teacher2_20 pres_teacher2_21 pres_teacher2_22 pres_teacher2_23 pres_teacher2_24 pres_teacher2_25 pres_teacher2_26 pres_teacher2_27 pres_teacher2_28 pres_teacher2_29 pres_teacher2_30 pres_teacher2_31 pres_teacher2_32 pres_teacher2_33 pres_teacher2_34 pres_teacher2_35 pres_teacher2_36 pres_teacher2_37 pres_teacher2_38 pres_teacher2_39 pres_teacher2_40 pres_teacher2_41 pres_teacher2_42 pres_teacher2_43 pres_teacher2_44 pres_teacher2_45 pres_teacher2_46 pres_teacher2_47 pres_teacher2_48 entre_teacher2_01 entre_teacher2_02 entre_teacher2_03 entre_teacher2_04 entre_teacher2_05 entre_teacher2_06 entre_teacher2_07 entre_teacher2_08 entre_teacher2_09 entre_teacher2_10 entre_teacher2_11 entre_teacher2_12 entre_teacher2_13 entre_teacher2_14 entre_teacher2_15 entre_teacher2_16 entre_teacher2_17 entre_teacher2_18 entre_teacher2_19 entre_teacher2_20 entre_teacher2_21 entre_teacher2_22 entre_teacher2_23 entre_teacher2_24 entre_teacher2_25 entre_teacher2_26 entre_teacher2_27 entre_teacher2_28 entre_teacher2_29 entre_teacher2_30 entre_teacher2_31 entre_teacher2_32 entre_teacher2_33 entre_teacher2_34 entre_teacher2_35 entre_teacher2_36 entre_teacher2_37 entre_teacher2_38 entre_teacher2_39 entre_teacher2_40 entre_teacher2_41 entre_teacher2_42 entre_teacher2_43 entre_teacher2_44 entre_teacher2_45 entre_teacher2_46 entre_teacher2_47 entre_teacher2_48 jogos_teacher_01 jogos_teacher_02 jogos_teacher_03 jogos_teacher_04 jogos_teacher_05 jogos_teacher_06 jogos_teacher_07 jogos_teacher_08 jogos_teacher_09 jogos_teacher_10 jogos_teacher_11 jogos_teacher_12 jogos_teacher_13 jogos_teacher_14 jogos_teacher_15 jogos_teacher_16 jogos_teacher_17 jogos_teacher_18 jogos_teacher_19 jogos_teacher_20 jogos_teacher_21 jogos_teacher_22 jogos_teacher_23 jogos_teacher_24 jogos_teacher_25 jogos_teacher_26 jogos_teacher_27 jogos_teacher_28 jogos_teacher_29 jogos_teacher_30 jogos_teacher_31 jogos_teacher_32 jogos_teacher_33 jogos_teacher_34 jogos_teacher_35 jogos_teacher_36 jogos_teacher_37 jogos_teacher_38 jogos_teacher_39 jogos_teacher_40 jogos_teacher_41 jogos_teacher_42 jogos_teacher_43 jogos_teacher_44 jogos_teacher_45 jogos_teacher_46 jogos_teacher_47 jogos_teacher_48 entre_teacher3_01 entre_teacher3_02 entre_teacher3_03 entre_teacher3_04 entre_teacher3_05 entre_teacher3_06 entre_teacher3_07 entre_teacher3_08 entre_teacher3_09 entre_teacher3_10 entre_teacher3_11 entre_teacher3_12 entre_teacher3_13 entre_teacher3_14 entre_teacher3_15 entre_teacher3_16 entre_teacher3_17 entre_teacher3_18 entre_teacher3_19 entre_teacher3_20 entre_teacher3_21 entre_teacher3_22 entre_teacher3_23 entre_teacher3_24 entre_teacher3_25 entre_teacher3_26 entre_teacher3_27 entre_teacher3_28 entre_teacher3_29 entre_teacher3_30 entre_teacher3_31 entre_teacher3_32 entre_teacher3_33 entre_teacher3_34 entre_teacher3_35 entre_teacher3_36 entre_teacher3_37 entre_teacher3_38 entre_teacher3_39 entre_teacher3_40 entre_teacher3_41 entre_teacher3_42 entre_teacher3_43 entre_teacher3_44 entre_teacher3_45 entre_teacher3_46 entre_teacher3_47 entre_teacher3_48 pres_stud1_01 pres_stud1_02 pres_stud1_03 pres_stud1_04 pres_stud1_05 pres_stud1_06 pres_stud1_07 pres_stud1_08 pres_stud1_09 pres_stud1_10 pres_stud1_11 pres_stud1_12 pres_stud1_13 pres_stud1_14 pres_stud1_15 pres_stud1_16 pres_stud1_17 pres_stud1_18 pres_stud1_19 pres_stud1_20 pres_stud1_21 pres_stud1_22 pres_stud1_23 pres_stud1_24 pres_stud1_25 pres_stud1_26 pres_stud1_27 pres_stud1_28 pres_stud1_29 pres_stud1_30 pres_stud1_31 pres_stud1_32 pres_stud1_33 pres_stud1_34 pres_stud1_35 pres_stud1_36 pres_stud1_37 pres_stud1_38 pres_stud1_39 pres_stud1_40 pres_stud2_01 pres_stud2_02 pres_stud2_03 pres_stud2_04 pres_stud2_05 pres_stud2_06 pres_stud2_07 pres_stud2_08 pres_stud2_09 pres_stud2_10 pres_stud2_11 pres_stud2_12 pres_stud2_13 pres_stud2_14 pres_stud2_15 pres_stud2_16 pres_stud2_17 pres_stud2_18 pres_stud2_19 pres_stud2_20 pres_stud2_21 pres_stud2_22 pres_stud2_23 pres_stud2_24 pres_stud2_25 pres_stud2_26 pres_stud2_27 pres_stud2_28 pres_stud2_29 pres_stud2_30 pres_stud2_31 pres_stud2_32 pres_stud2_33 pres_stud2_34 pres_stud2_35 pres_stud2_36 pres_stud2_37 pres_stud2_38 pres_stud2_39 pres_stud2_40 entre_parent_01 entre_parent_02 entre_parent_03 entre_parent_04 entre_parent_05 entre_parent_06 entre_parent_07 entre_parent_08 entre_parent_09 entre_parent_10 entre_parent_11 entre_parent_12 entre_parent_13 entre_parent_14 entre_parent_15 entre_parent_16 entre_parent_17 entre_parent_18 entre_parent_19 entre_parent_20 entre_parent_21 entre_parent_22 entre_parent_23 entre_parent_24 entre_parent_25 entre_parent_26 entre_parent_27 entre_parent_28 entre_parent_29 entre_parent_30 entre_parent_31 entre_parent_32 entre_parent_33 entre_parent_34 entre_parent_35 entre_parent_36 entre_parent_37 entre_parent_38 entre_parent_39 entre_parent_40 jogos_parent_01 jogos_parent_02 jogos_parent_03 jogos_parent_04 jogos_parent_05 jogos_parent_06 jogos_parent_07 jogos_parent_08 jogos_parent_09 jogos_parent_10 jogos_parent_11 jogos_parent_12 jogos_parent_13 jogos_parent_14 jogos_parent_15 jogos_parent_16 jogos_parent_17 jogos_parent_18 jogos_parent_19 jogos_parent_20 jogos_parent_21 jogos_parent_22 jogos_parent_23 jogos_parent_24 jogos_parent_25 jogos_parent_26 jogos_parent_27 jogos_parent_28 jogos_parent_29 jogos_parent_30 jogos_parent_31 jogos_parent_32 jogos_parent_33 jogos_parent_34 jogos_parent_35 jogos_parent_36 jogos_parent_37 jogos_parent_38 jogos_parent_39 jogos_parent_40, replace

lab val test_por_01 test_por_02 test_por_03 test_por_04 test_por_05 test_por_06 test_por_07 test_por_08 test_por_09 test_por_10 test_por_11 test_por_12 test_por_13 test_por_14 test_por_15 test_por_16 test_por_17 test_por_18 test_por_19 test_por_20 test_por_21 test_por_22 test_por_23 test_por_24 test_por_25 test_por_26 test_por_27 test_por_28 test_por_29 test_por_30 test_por_31 test_por_32 test_mat_01 test_mat_02 test_mat_03 test_mat_04 test_mat_05 test_mat_06 test_mat_07 test_mat_08 test_mat_09 test_mat_10 test_mat_11 test_mat_12 test_mat_13 test_mat_14 test_mat_15 test_mat_16 test_mat_17 test_mat_18 test_mat_19 test_mat_20 test_mat_21 test_mat_22 test_mat_23 test_mat_24 test_mat_25 test_mat_26 test_mat_27 test_mat_28 test_mat_29 test_mat_30 test_mat_31 test_mat_32 dummy

foreach var in test_por_01 test_por_02 test_por_03 test_por_04 test_por_05 test_por_06 test_por_07 test_por_08 test_por_09 test_por_10 test_por_11 test_por_12 test_por_13 test_por_14 test_por_15 test_por_16 test_por_17 test_por_18 test_por_19 test_por_20 test_por_21 test_por_22 test_por_23 test_por_24 test_por_25 test_por_26 test_por_27 test_por_28 test_por_29 test_por_30 test_por_31 test_por_32 test_mat_01 test_mat_02 test_mat_03 test_mat_04 test_mat_05 test_mat_06 test_mat_07 test_mat_08 test_mat_09 test_mat_10 test_mat_11 test_mat_12 test_mat_13 test_mat_14 test_mat_15 test_mat_16 test_mat_17 test_mat_18 test_mat_19 test_mat_20 test_mat_21 test_mat_22 test_mat_23 test_mat_24 test_mat_25 test_mat_26 test_mat_27 test_mat_28 test_mat_29 test_mat_30 test_mat_31 test_mat_32{
replace `var'=. if `var'==9
}

foreach var in test_por_01 test_por_02 test_por_03 test_por_04 test_por_05 test_por_06 test_por_07 test_por_08 test_por_09 test_por_10 test_por_11 test_por_12 test_por_13 test_por_14 test_por_15 test_por_16 test_por_17 test_por_18 test_por_19 test_por_20 test_por_21 test_por_22 test_por_23 test_por_24 test_por_25 test_por_26 test_por_27 test_por_28 test_por_29 test_por_30 test_por_31 test_por_32{
lab var `var' "Indicator for portuguese test conducted in class"
}

foreach var in test_mat_01 test_mat_02 test_mat_03 test_mat_04 test_mat_05 test_mat_06 test_mat_07 test_mat_08 test_mat_09 test_mat_10 test_mat_11 test_mat_12 test_mat_13 test_mat_14 test_mat_15 test_mat_16 test_mat_17 test_mat_18 test_mat_19 test_mat_20 test_mat_21 test_mat_22 test_mat_23 test_mat_24 test_mat_25 test_mat_26 test_mat_27 test_mat_28 test_mat_29 test_mat_30 test_mat_31 test_mat_32{
lab var `var' "Indicator for mathematics test conducted in class"
}

lab val pres_teacher1_01 pres_teacher1_02 pres_teacher1_03 pres_teacher1_04 pres_teacher1_05 pres_teacher1_06 pres_teacher1_07 pres_teacher1_08 pres_teacher1_09 pres_teacher1_10 pres_teacher1_11 pres_teacher1_12 pres_teacher1_13 pres_teacher1_14 pres_teacher1_15 pres_teacher1_16 pres_teacher1_17 pres_teacher1_18 pres_teacher1_19 pres_teacher1_20 pres_teacher1_21 pres_teacher1_22 pres_teacher1_23 pres_teacher1_24 pres_teacher1_25 pres_teacher1_26 pres_teacher1_27 pres_teacher1_28 pres_teacher1_29 pres_teacher1_30 pres_teacher1_31 pres_teacher1_32 pres_teacher1_33 pres_teacher1_34 pres_teacher1_35 pres_teacher1_36 pres_teacher1_37 pres_teacher1_38 pres_teacher1_39 pres_teacher1_40 pres_teacher1_41 pres_teacher1_42 pres_teacher1_43 pres_teacher1_44 pres_teacher1_45 pres_teacher1_46 pres_teacher1_47 pres_teacher1_48 entre_teacher1_01 entre_teacher1_02 entre_teacher1_03 entre_teacher1_04 entre_teacher1_05 entre_teacher1_06 entre_teacher1_07 entre_teacher1_08 entre_teacher1_09 entre_teacher1_10 entre_teacher1_11 entre_teacher1_12 entre_teacher1_13 entre_teacher1_14 entre_teacher1_15 entre_teacher1_16 entre_teacher1_17 entre_teacher1_18 entre_teacher1_19 entre_teacher1_20 entre_teacher1_21 entre_teacher1_22 entre_teacher1_23 entre_teacher1_24 entre_teacher1_25 entre_teacher1_26 entre_teacher1_27 entre_teacher1_28 entre_teacher1_29 entre_teacher1_30 entre_teacher1_31 entre_teacher1_32 entre_teacher1_33 entre_teacher1_34 entre_teacher1_35 entre_teacher1_36 entre_teacher1_37 entre_teacher1_38 entre_teacher1_39 entre_teacher1_40 entre_teacher1_41 entre_teacher1_42 entre_teacher1_43 entre_teacher1_44 entre_teacher1_45 entre_teacher1_46 entre_teacher1_47 entre_teacher1_48 pres_teacher2_01 pres_teacher2_02 pres_teacher2_03 pres_teacher2_04 pres_teacher2_05 pres_teacher2_06 pres_teacher2_07 pres_teacher2_08 pres_teacher2_09 pres_teacher2_10 pres_teacher2_11 pres_teacher2_12 pres_teacher2_13 pres_teacher2_14 pres_teacher2_15 pres_teacher2_16 pres_teacher2_17 pres_teacher2_18 pres_teacher2_19 pres_teacher2_20 pres_teacher2_21 pres_teacher2_22 pres_teacher2_23 pres_teacher2_24 pres_teacher2_25 pres_teacher2_26 pres_teacher2_27 pres_teacher2_28 pres_teacher2_29 pres_teacher2_30 pres_teacher2_31 pres_teacher2_32 pres_teacher2_33 pres_teacher2_34 pres_teacher2_35 pres_teacher2_36 pres_teacher2_37 pres_teacher2_38 pres_teacher2_39 pres_teacher2_40 pres_teacher2_41 pres_teacher2_42 pres_teacher2_43 pres_teacher2_44 pres_teacher2_45 pres_teacher2_46 pres_teacher2_47 pres_teacher2_48 entre_teacher2_01 entre_teacher2_02 entre_teacher2_03 entre_teacher2_04 entre_teacher2_05 entre_teacher2_06 entre_teacher2_07 entre_teacher2_08 entre_teacher2_09 entre_teacher2_10 entre_teacher2_11 entre_teacher2_12 entre_teacher2_13 entre_teacher2_14 entre_teacher2_15 entre_teacher2_16 entre_teacher2_17 entre_teacher2_18 entre_teacher2_19 entre_teacher2_20 entre_teacher2_21 entre_teacher2_22 entre_teacher2_23 entre_teacher2_24 entre_teacher2_25 entre_teacher2_26 entre_teacher2_27 entre_teacher2_28 entre_teacher2_29 entre_teacher2_30 entre_teacher2_31 entre_teacher2_32 entre_teacher2_33 entre_teacher2_34 entre_teacher2_35 entre_teacher2_36 entre_teacher2_37 entre_teacher2_38 entre_teacher2_39 entre_teacher2_40 entre_teacher2_41 entre_teacher2_42 entre_teacher2_43 entre_teacher2_44 entre_teacher2_45 entre_teacher2_46 entre_teacher2_47 entre_teacher2_48 entre_teacher3_01 entre_teacher3_02 entre_teacher3_03 entre_teacher3_04 entre_teacher3_05 entre_teacher3_06 entre_teacher3_07 entre_teacher3_08 entre_teacher3_09 entre_teacher3_10 entre_teacher3_11 entre_teacher3_12 entre_teacher3_13 entre_teacher3_14 entre_teacher3_15 entre_teacher3_16 entre_teacher3_17 entre_teacher3_18 entre_teacher3_19 entre_teacher3_20 entre_teacher3_21 entre_teacher3_22 entre_teacher3_23 entre_teacher3_24 entre_teacher3_25 entre_teacher3_26 entre_teacher3_27 entre_teacher3_28 entre_teacher3_29 entre_teacher3_30 entre_teacher3_31 entre_teacher3_32 entre_teacher3_33 entre_teacher3_34 entre_teacher3_35 entre_teacher3_36 entre_teacher3_37 entre_teacher3_38 entre_teacher3_39 entre_teacher3_40 entre_teacher3_41 entre_teacher3_42 entre_teacher3_43 entre_teacher3_44 entre_teacher3_45 entre_teacher3_46 entre_teacher3_47 entre_teacher3_48 pres_stud1_01 pres_stud1_02 pres_stud1_03 pres_stud1_04 pres_stud1_05 pres_stud1_06 pres_stud1_07 pres_stud1_08 pres_stud1_09 pres_stud1_10 pres_stud1_11 pres_stud1_12 pres_stud1_13 pres_stud1_14 pres_stud1_15 pres_stud1_16 pres_stud1_17 pres_stud1_18 pres_stud1_19 pres_stud1_20 pres_stud1_21 pres_stud1_22 pres_stud1_23 pres_stud1_24 pres_stud1_25 pres_stud1_26 pres_stud1_27 pres_stud1_28 pres_stud1_29 pres_stud1_30 pres_stud1_31 pres_stud1_32 pres_stud1_33 pres_stud1_34 pres_stud1_35 pres_stud1_36 pres_stud1_37 pres_stud1_38 pres_stud1_39 pres_stud1_40 pres_stud2_01 pres_stud2_02 pres_stud2_03 pres_stud2_04 pres_stud2_05 pres_stud2_06 pres_stud2_07 pres_stud2_08 pres_stud2_09 pres_stud2_10 pres_stud2_11 pres_stud2_12 pres_stud2_13 pres_stud2_14 pres_stud2_15 pres_stud2_16 pres_stud2_17 pres_stud2_18 pres_stud2_19 pres_stud2_20 pres_stud2_21 pres_stud2_22 pres_stud2_23 pres_stud2_24 pres_stud2_25 pres_stud2_26 pres_stud2_27 pres_stud2_28 pres_stud2_29 pres_stud2_30 pres_stud2_31 pres_stud2_32 pres_stud2_33 pres_stud2_34 pres_stud2_35 pres_stud2_36 pres_stud2_37 pres_stud2_38 pres_stud2_39 pres_stud2_40 entre_parent_01 entre_parent_02 entre_parent_03 entre_parent_04 entre_parent_05 entre_parent_06 entre_parent_07 entre_parent_08 entre_parent_09 entre_parent_10 entre_parent_11 entre_parent_12 entre_parent_13 entre_parent_14 entre_parent_15 entre_parent_16 entre_parent_17 entre_parent_18 entre_parent_19 entre_parent_20 entre_parent_21 entre_parent_22 entre_parent_23 entre_parent_24 entre_parent_25 entre_parent_26 entre_parent_27 entre_parent_28 entre_parent_29 entre_parent_30 entre_parent_31 entre_parent_32 entre_parent_33 entre_parent_34 entre_parent_35 entre_parent_36 entre_parent_37 entre_parent_38 entre_parent_39 entre_parent_40 dummy

foreach var in pres_teacher1_01 pres_teacher1_02 pres_teacher1_03 pres_teacher1_04 pres_teacher1_05 pres_teacher1_06 pres_teacher1_07 pres_teacher1_08 pres_teacher1_09 pres_teacher1_10 pres_teacher1_11 pres_teacher1_12 pres_teacher1_13 pres_teacher1_14 pres_teacher1_15 pres_teacher1_16 pres_teacher1_17 pres_teacher1_18 pres_teacher1_19 pres_teacher1_20 pres_teacher1_21 pres_teacher1_22 pres_teacher1_23 pres_teacher1_24 pres_teacher1_25 pres_teacher1_26 pres_teacher1_27 pres_teacher1_28 pres_teacher1_29 pres_teacher1_30 pres_teacher1_31 pres_teacher1_32 pres_teacher1_33 pres_teacher1_34 pres_teacher1_35 pres_teacher1_36 pres_teacher1_37 pres_teacher1_38 pres_teacher1_39 pres_teacher1_40 pres_teacher1_41 pres_teacher1_42 pres_teacher1_43 pres_teacher1_44 pres_teacher1_45 pres_teacher1_46 pres_teacher1_47 pres_teacher1_48{
lab var `var' "Teacher attendance during first visit"
replace `var' = . if `var'==9
}

foreach var in pres_teacher2_01 pres_teacher2_02 pres_teacher2_03 pres_teacher2_04 pres_teacher2_05 pres_teacher2_06 pres_teacher2_07 pres_teacher2_08 pres_teacher2_09 pres_teacher2_10 pres_teacher2_11 pres_teacher2_12 pres_teacher2_13 pres_teacher2_14 pres_teacher2_15 pres_teacher2_16 pres_teacher2_17 pres_teacher2_18 pres_teacher2_19 pres_teacher2_20 pres_teacher2_21 pres_teacher2_22 pres_teacher2_23 pres_teacher2_24 pres_teacher2_25 pres_teacher2_26 pres_teacher2_27 pres_teacher2_28 pres_teacher2_29 pres_teacher2_30 pres_teacher2_31 pres_teacher2_32 pres_teacher2_33 pres_teacher2_34 pres_teacher2_35 pres_teacher2_36 pres_teacher2_37 pres_teacher2_38 pres_teacher2_39 pres_teacher2_40 pres_teacher2_41 pres_teacher2_42 pres_teacher2_43 pres_teacher2_44 pres_teacher2_45 pres_teacher2_46 pres_teacher2_47 pres_teacher2_48{
lab var `var' "Teacher attendance during second visit"
}

foreach var in entre_teacher1_01 entre_teacher1_02 entre_teacher1_03 entre_teacher1_04 entre_teacher1_05 entre_teacher1_06 entre_teacher1_07 entre_teacher1_08 entre_teacher1_09 entre_teacher1_10 entre_teacher1_11 entre_teacher1_12 entre_teacher1_13 entre_teacher1_14 entre_teacher1_15 entre_teacher1_16 entre_teacher1_17 entre_teacher1_18 entre_teacher1_19 entre_teacher1_20 entre_teacher1_21 entre_teacher1_22 entre_teacher1_23 entre_teacher1_24 entre_teacher1_25 entre_teacher1_26 entre_teacher1_27 entre_teacher1_28 entre_teacher1_29 entre_teacher1_30 entre_teacher1_31 entre_teacher1_32 entre_teacher1_33 entre_teacher1_34 entre_teacher1_35 entre_teacher1_36 entre_teacher1_37 entre_teacher1_38 entre_teacher1_39 entre_teacher1_40 entre_teacher1_41 entre_teacher1_42 entre_teacher1_43 entre_teacher1_44 entre_teacher1_45 entre_teacher1_46 entre_teacher1_47 entre_teacher1_48{
lab var `var' "Teacher interviewed during first visit"
}

foreach var in entre_teacher2_01 entre_teacher2_02 entre_teacher2_03 entre_teacher2_04 entre_teacher2_05 entre_teacher2_06 entre_teacher2_07 entre_teacher2_08 entre_teacher2_09 entre_teacher2_10 entre_teacher2_11 entre_teacher2_12 entre_teacher2_13 entre_teacher2_14 entre_teacher2_15 entre_teacher2_16 entre_teacher2_17 entre_teacher2_18 entre_teacher2_19 entre_teacher2_20 entre_teacher2_21 entre_teacher2_22 entre_teacher2_23 entre_teacher2_24 entre_teacher2_25 entre_teacher2_26 entre_teacher2_27 entre_teacher2_28 entre_teacher2_29 entre_teacher2_30 entre_teacher2_31 entre_teacher2_32 entre_teacher2_33 entre_teacher2_34 entre_teacher2_35 entre_teacher2_36 entre_teacher2_37 entre_teacher2_38 entre_teacher2_39 entre_teacher2_40 entre_teacher2_41 entre_teacher2_42 entre_teacher2_43 entre_teacher2_44 entre_teacher2_45 entre_teacher2_46 entre_teacher2_47 entre_teacher2_48{
lab var `var' "Teacher interviewed during second visit"
}

foreach var in entre_teacher3_01 entre_teacher3_02 entre_teacher3_03 entre_teacher3_04 entre_teacher3_05 entre_teacher3_06 entre_teacher3_07 entre_teacher3_08 entre_teacher3_09 entre_teacher3_10 entre_teacher3_11 entre_teacher3_12 entre_teacher3_13 entre_teacher3_14 entre_teacher3_15 entre_teacher3_16 entre_teacher3_17 entre_teacher3_18 entre_teacher3_19 entre_teacher3_20 entre_teacher3_21 entre_teacher3_22 entre_teacher3_23 entre_teacher3_24 entre_teacher3_25 entre_teacher3_26 entre_teacher3_27 entre_teacher3_28 entre_teacher3_29 entre_teacher3_30 entre_teacher3_31 entre_teacher3_32 entre_teacher3_33 entre_teacher3_34 entre_teacher3_35 entre_teacher3_36 entre_teacher3_37 entre_teacher3_38 entre_teacher3_39 entre_teacher3_40 entre_teacher3_41 entre_teacher3_42 entre_teacher3_43 entre_teacher3_44 entre_teacher3_45 entre_teacher3_46 entre_teacher3_47 entre_teacher3_48{
lab var `var' "Teacher interviewed during third visit"
replace `var' = . if `var'==9
}

foreach var in jogos_teacher_01 jogos_teacher_02 jogos_teacher_03 jogos_teacher_04 jogos_teacher_05 jogos_teacher_06 jogos_teacher_07 jogos_teacher_08 jogos_teacher_09 jogos_teacher_10 jogos_teacher_11 jogos_teacher_12 jogos_teacher_13 jogos_teacher_14 jogos_teacher_15 jogos_teacher_16 jogos_teacher_17 jogos_teacher_18 jogos_teacher_19 jogos_teacher_20 jogos_teacher_21 jogos_teacher_22 jogos_teacher_23 jogos_teacher_24 jogos_teacher_25 jogos_teacher_26 jogos_teacher_27 jogos_teacher_28 jogos_teacher_29 jogos_teacher_30 jogos_teacher_31 jogos_teacher_32 jogos_teacher_33 jogos_teacher_34 jogos_teacher_35 jogos_teacher_36 jogos_teacher_37 jogos_teacher_38 jogos_teacher_39 jogos_teacher_40 jogos_teacher_41 jogos_teacher_42 jogos_teacher_43 jogos_teacher_44 jogos_teacher_45 jogos_teacher_46 jogos_teacher_47 jogos_teacher_48{
lab var `var' "Teacher's BLUE game number"
replace `var' = . if `var'==9
}

foreach var in pres_stud1_01 pres_stud1_02 pres_stud1_03 pres_stud1_04 pres_stud1_05 pres_stud1_06 pres_stud1_07 pres_stud1_08 pres_stud1_09 pres_stud1_10 pres_stud1_11 pres_stud1_12 pres_stud1_13 pres_stud1_14 pres_stud1_15 pres_stud1_16 pres_stud1_17 pres_stud1_18 pres_stud1_19 pres_stud1_20 pres_stud1_21 pres_stud1_22 pres_stud1_23 pres_stud1_24 pres_stud1_25 pres_stud1_26 pres_stud1_27 pres_stud1_28 pres_stud1_29 pres_stud1_30 pres_stud1_31 pres_stud1_32 pres_stud1_33 pres_stud1_34 pres_stud1_35 pres_stud1_36 pres_stud1_37 pres_stud1_38 pres_stud1_39 pres_stud1_40{
lab var `var' "Student attendance during first visit"
replace `var' = . if `var'==9
}

foreach var in pres_stud2_01 pres_stud2_02 pres_stud2_03 pres_stud2_04 pres_stud2_05 pres_stud2_06 pres_stud2_07 pres_stud2_08 pres_stud2_09 pres_stud2_10 pres_stud2_11 pres_stud2_12 pres_stud2_13 pres_stud2_14 pres_stud2_15 pres_stud2_16 pres_stud2_17 pres_stud2_18 pres_stud2_19 pres_stud2_20 pres_stud2_21 pres_stud2_22 pres_stud2_23 pres_stud2_24 pres_stud2_25 pres_stud2_26 pres_stud2_27 pres_stud2_28 pres_stud2_29 pres_stud2_30 pres_stud2_31 pres_stud2_32 pres_stud2_33 pres_stud2_34 pres_stud2_35 pres_stud2_36 pres_stud2_37 pres_stud2_38 pres_stud2_39 pres_stud2_40{
lab var `var' "Student attendance during second visit"
}

foreach var in entre_parent_01 entre_parent_02 entre_parent_03 entre_parent_04 entre_parent_05 entre_parent_06 entre_parent_07 entre_parent_08 entre_parent_09 entre_parent_10 entre_parent_11 entre_parent_12 entre_parent_13 entre_parent_14 entre_parent_15 entre_parent_16 entre_parent_17 entre_parent_18 entre_parent_19 entre_parent_20 entre_parent_21 entre_parent_22 entre_parent_23 entre_parent_24 entre_parent_25 entre_parent_26 entre_parent_27 entre_parent_28 entre_parent_29 entre_parent_30 entre_parent_31 entre_parent_32 entre_parent_33 entre_parent_34 entre_parent_35 entre_parent_36 entre_parent_37 entre_parent_38 entre_parent_39 entre_parent_40{
lab var `var' "Parent was interviewed"
}

foreach var in jogos_parent_01 jogos_parent_02 jogos_parent_03 jogos_parent_04 jogos_parent_05 jogos_parent_06 jogos_parent_07 jogos_parent_08 jogos_parent_09 jogos_parent_10 jogos_parent_11 jogos_parent_12 jogos_parent_13 jogos_parent_14 jogos_parent_15 jogos_parent_16 jogos_parent_17 jogos_parent_18 jogos_parent_19 jogos_parent_20 jogos_parent_21 jogos_parent_22 jogos_parent_23 jogos_parent_24 jogos_parent_25 jogos_parent_26 jogos_parent_27 jogos_parent_28 jogos_parent_29 jogos_parent_30 jogos_parent_31 jogos_parent_32 jogos_parent_33 jogos_parent_34 jogos_parent_35 jogos_parent_36 jogos_parent_37 jogos_parent_38 jogos_parent_39 jogos_parent_40{
lab var `var' "Parent's ORANGE game number"
replace `var' = . if `var'==99
}

egen teacher_attendance1 = rowmean(pres_teacher1_01 pres_teacher1_02 pres_teacher1_03 pres_teacher1_04 pres_teacher1_05 pres_teacher1_06 pres_teacher1_07 pres_teacher1_08 pres_teacher1_09 pres_teacher1_10 pres_teacher1_11 pres_teacher1_12 pres_teacher1_13 pres_teacher1_14 pres_teacher1_15 pres_teacher1_16 pres_teacher1_17 pres_teacher1_18 pres_teacher1_19 pres_teacher1_20 pres_teacher1_21 pres_teacher1_22 pres_teacher1_23 pres_teacher1_24 pres_teacher1_25 pres_teacher1_26 pres_teacher1_27 pres_teacher1_28 pres_teacher1_29 pres_teacher1_30 pres_teacher1_31 pres_teacher1_32 pres_teacher1_33 pres_teacher1_34 pres_teacher1_35 pres_teacher1_36 pres_teacher1_37 pres_teacher1_38 pres_teacher1_39 pres_teacher1_40 pres_teacher1_41 pres_teacher1_42 pres_teacher1_43 pres_teacher1_44 pres_teacher1_45 pres_teacher1_46 pres_teacher1_47 pres_teacher1_48)
egen teacher_attendance2 = rowmean(pres_teacher2_01 pres_teacher2_02 pres_teacher2_03 pres_teacher2_04 pres_teacher2_05 pres_teacher2_06 pres_teacher2_07 pres_teacher2_08 pres_teacher2_09 pres_teacher2_10 pres_teacher2_11 pres_teacher2_12 pres_teacher2_13 pres_teacher2_14 pres_teacher2_15 pres_teacher2_16 pres_teacher2_17 pres_teacher2_18 pres_teacher2_19 pres_teacher2_20 pres_teacher2_21 pres_teacher2_22 pres_teacher2_23 pres_teacher2_24 pres_teacher2_25 pres_teacher2_26 pres_teacher2_27 pres_teacher2_28 pres_teacher2_29 pres_teacher2_30 pres_teacher2_31 pres_teacher2_32 pres_teacher2_33 pres_teacher2_34 pres_teacher2_35 pres_teacher2_36 pres_teacher2_37 pres_teacher2_38 pres_teacher2_39 pres_teacher2_40 pres_teacher2_41 pres_teacher2_42 pres_teacher2_43 pres_teacher2_44 pres_teacher2_45 pres_teacher2_46 pres_teacher2_47 pres_teacher2_48)
egen student_attendance1 = rowmean(pres_stud1_01 pres_stud1_02 pres_stud1_03 pres_stud1_04 pres_stud1_05 pres_stud1_06 pres_stud1_07 pres_stud1_08 pres_stud1_09 pres_stud1_10 pres_stud1_11 pres_stud1_12 pres_stud1_13 pres_stud1_14 pres_stud1_15 pres_stud1_16 pres_stud1_17 pres_stud1_18 pres_stud1_19 pres_stud1_20 pres_stud1_21 pres_stud1_22 pres_stud1_23 pres_stud1_24 pres_stud1_25 pres_stud1_26 pres_stud1_27 pres_stud1_28 pres_stud1_29 pres_stud1_30 pres_stud1_31 pres_stud1_32 pres_stud1_33 pres_stud1_34 pres_stud1_35 pres_stud1_36 pres_stud1_37 pres_stud1_38 pres_stud1_39 pres_stud1_40)
egen student_attendance2 = rowmean(pres_stud2_01 pres_stud2_02 pres_stud2_03 pres_stud2_04 pres_stud2_05 pres_stud2_06 pres_stud2_07 pres_stud2_08 pres_stud2_09 pres_stud2_10 pres_stud2_11 pres_stud2_12 pres_stud2_13 pres_stud2_14 pres_stud2_15 pres_stud2_16 pres_stud2_17 pres_stud2_18 pres_stud2_19 pres_stud2_20 pres_stud2_21 pres_stud2_22 pres_stud2_23 pres_stud2_24 pres_stud2_25 pres_stud2_26 pres_stud2_27 pres_stud2_28 pres_stud2_29 pres_stud2_30 pres_stud2_31 pres_stud2_32 pres_stud2_33 pres_stud2_34 pres_stud2_35 pres_stud2_36 pres_stud2_37 pres_stud2_38 pres_stud2_39 pres_stud2_40)

lab var teacher_attendance1 "Average teacher attendance first visit"
lab var teacher_attendance2 "Average teacher attendance second visit"
lab var student_attendance1 "Average student attendance first visit"
lab var student_attendance2 "Average student attendance second visit"

order teacher_attendance1 teacher_attendance2 student_attendance1 student_attendance2, after(supervisor_id)

drop supervisor_name

egen test_done = rowtotal(test_por_01 test_por_02 test_por_03 test_por_04 test_por_05 test_por_06 test_por_07 test_por_08 test_por_09 test_por_10 test_por_11 test_por_12 test_por_13 test_por_14 test_por_15 test_por_16 test_por_17 test_por_18 test_por_19 test_por_20 test_por_21 test_por_22 test_por_23 test_por_24 test_por_25 test_por_26 test_por_27 test_por_28 test_por_29 test_por_30 test_por_31 test_por_32)
egen turmas = rownonmiss(test_por_01 test_por_02 test_por_03 test_por_04 test_por_05 test_por_06 test_por_07 test_por_08 test_por_09 test_por_10 test_por_11 test_por_12 test_por_13 test_por_14 test_por_15 test_por_16 test_por_17 test_por_18 test_por_19 test_por_20 test_por_21 test_por_22 test_por_23 test_por_24 test_por_25 test_por_26 test_por_27 test_por_28 test_por_29 test_por_30 test_por_31 test_por_32)

gen coverage =  test_done / turmas

replace date1 = 13 if school_id==7
replace month1 = 10 if school_id==9
replace month2 = 11 if school_id==47
replace date1 = 24 if school_id==120

replace date2 = 5 if school_id==103

replace date1 = 5 if school_id==124
replace month1 = 8 if school_id==124
replace date2 = 12 if school_id==124
replace month2 = 8 if school_id==124


gen days_passed = date2 - date1 if month2==month1
replace days_passed = date2 - date1 + 31 if month2>month1 & inlist(month1,7,8,10)
replace days_passed = date2 - date1 + 30 if month2>month1 & inlist(month1,9,11)

replace days_passed = days_passed + 61 if school_id==57

order days_passed, after(month3)

lab var days_passed "Number of days passed between first two visits"



***********

gen municipality = .
replace municipality = 1 if inlist(school_id,1,2,3,4,5,6,7,8,9,10,12,13,14,15,16,17,18,19,20,21,22,24,25,26,27,28,29,30,31,32,33,34,35,37,40,45,61,86,110)
replace municipality = 2 if inlist(school_id,23,43,44,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,62,63,64,65,66,67,68,69,70,71,72,73,75,76,77,78,79,80,81)
replace municipality = 3 if inlist(school_id,11,36,38,39,41,42,74,82,83,84,85,87,88,89,90,91,92,93,94,95,96,97,98,99,101,102,103,104,105)
replace municipality = 4 if inlist(school_id,118,119,120,121,122,123,124,125)
replace municipality = 5 if inlist(school_id,100,112,113,114,115,116,117)
replace municipality = 6 if inlist(school_id,109,111)
replace municipality = 7 if inlist(school_id,106,107)
replace municipality = 8 if inlist(school_id,126)
replace municipality = 9 if inlist(school_id,108)


gen treatment = .
replace treatment = 0 if inlist(school_id,3,4,7,10,16,18,20,23,26,29,33,39,42,53,55,62,63,64,65,78,81,84,87,88,89,92,98,108,109,116,117,121)
replace treatment = 1 if inlist(school_id,15,19,22,27,32,36,37,40,49,51,56,57,58,61,66,68,72,76,79,82,83,86,91,95,100,102,103,106,110,114,125,126)
replace treatment = 2 if inlist(school_id,1,5,6,11,12,14,21,24,25,31,41,48,50,52,59,70,73,77,80,90,93,94,101,105,107,111,112,113,119,120,124)
replace treatment = 3 if inlist(school_id,2,8,9,13,17,28,30,34,35,38,43,44,45,46,47,54,60,67,69,71,74,75,85,96,97,99,104,115,118,122,123)

order municipality treatment, after(school_id)

lab var municipality "Municipality"
lab var treatment "Treatment group"

#delimit ;
;
label define treatment
0	"Control group"
1	"Door-to-door"
2	"Meetings"
3	"Both treatments"
;
label define municipality
1	"Sumbe"
2	"Porto Amboim"
3	"Gabela"
4	"Conda"
5	"Ebo"
6	"Quilenda"
7	"Seles"
8	"Cassongue"
9	"Quibala"
;
#delimit cr

lab val municipality municipality
lab val treatment treatment


*************


drop test_done turmas coverage

save "$Endline_dtRaw/_intermediate files/fda.dta", replace

keep 	school_id municipality treatment date1 month1 date2 month2 date3 month3 ///
		days_passed supervisor_id teacher_attendance1 teacher_attendance2 		///
		student_attendance1 student_attendance2									///
		///
		pres_teacher*

rename pres_teacher1_0* pres_teacher1_*
rename pres_teacher2_0* pres_teacher2_*




reshape long pres_teacher1_ pres_teacher2_, i(school_id) j(teacher_id)

rename pres_teacher1_ pres_teacher1
rename pres_teacher2_ pres_teacher2

order school_id teacher_id municipality treatment pres_teacher1 pres_teacher2
keep school_id teacher_id municipality treatment pres_teacher1 pres_teacher2

save "$Endline_dtRaw/_intermediate files/teacherattendance.dta", replace


use "$Endline_dtRaw/_intermediate files/fda.dta", replace


keep 	school_id municipality treatment date1 month1 date2 month2 date3 month3 ///
		days_passed supervisor_id teacher_attendance1 teacher_attendance2 		///
		student_attendance1 student_attendance2									///
		///
		pres_stud*

rename pres_stud1_0* pres_stud1_*
rename pres_stud2_0* pres_stud2_*

reshape long pres_stud1_ pres_stud2_, i(school_id) j(parent_id)

rename pres_stud1_ pres_stud1
rename pres_stud2_ pres_stud2

order school_id parent_id municipality treatment pres_stud1 pres_stud2
keep school_id parent_id municipality treatment pres_stud1 pres_stud2

save "$Endline_dtRaw/_intermediate files/studentattendance.dta", replace

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


use "$Endline_dtRaw/other/GPS_ANGOLA.dta", clear

rename id school_id

***********



gen municipality = .
replace municipality = 1 if inlist(school_id,1,2,3,4,5,6,7,8,9,10,12,13,14,15,16,17,18,19,20,21,22,24,25,26,27,28,29,30,31,32,33,34,35,37,40,45,61,86,110)
replace municipality = 2 if inlist(school_id,23,43,44,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,62,63,64,65,66,67,68,69,70,71,72,73,75,76,77,78,79,80,81)
replace municipality = 3 if inlist(school_id,11,36,38,39,41,42,74,82,83,84,85,87,88,89,90,91,92,93,94,95,96,97,98,99,101,102,103,104,105)
replace municipality = 4 if inlist(school_id,118,119,120,121,122,123,124,125)
replace municipality = 5 if inlist(school_id,100,112,113,114,115,116,117)
replace municipality = 6 if inlist(school_id,109,111)
replace municipality = 7 if inlist(school_id,106,107)
replace municipality = 8 if inlist(school_id,126)
replace municipality = 9 if inlist(school_id,108)


gen treatment = .
replace treatment = 0 if inlist(school_id,3,4,7,10,16,18,20,23,26,29,33,39,42,53,55,62,63,64,65,78,81,84,87,88,89,92,98,108,109,116,117,121)
replace treatment = 1 if inlist(school_id,15,19,22,27,32,36,37,40,49,51,56,57,58,61,66,68,72,76,79,82,83,86,91,95,100,102,103,106,110,114,125,126)
replace treatment = 2 if inlist(school_id,1,5,6,11,12,14,21,24,25,31,41,48,50,52,59,70,73,77,80,90,93,94,101,105,107,111,112,113,119,120,124)
replace treatment = 3 if inlist(school_id,2,8,9,13,17,28,30,34,35,38,43,44,45,46,47,54,60,67,69,71,74,75,85,96,97,99,104,115,118,122,123)

order municipality treatment, after(school_id)

lab var municipality "Municipality"
lab var treatment "Treatment group"

#delimit ;
;
label define treatment
0	"Control group"
1	"Door-to-door"
2	"Meetings"
3	"Both treatments"
;
label define municipality
1	"Sumbe"
2	"Porto Amboim"
3	"Gabela"
4	"Conda"
5	"Ebo"
6	"Quilenda"
7	"Seles"
8	"Cassongue"
9	"Quibala"
;
#delimit cr

lab val municipality municipality
lab val treatment treatment



// Define URBAN using GPS coordinates

gen closest_urban = 0
replace closest_urban = 1 if inlist(municipality,1,7,8)
replace closest_urban = 2 if inlist(municipality,2)
replace closest_urban = 3 if inlist(municipality,3,4,5,6,9)

gen closest_urban_lat = 0
replace closest_urban_lat = -11.202504 if closest_urban==1
replace closest_urban_lat = -10.730719 if closest_urban==2
replace closest_urban_lat = -10.851092 if closest_urban==3

gen closest_urban_lon = 0
replace closest_urban_lon = 13.842253 if closest_urban==1
replace closest_urban_lon = 13.752276 if closest_urban==2
replace closest_urban_lon = 14.372729 if closest_urban==3

gen closest_urban_dist = .
replace closest_urban_dist =(sqrt(((Lat_school-closest_urban_lat)^2)+((Lon_school-closest_urban_lon)^2)))*111.12

gen urban = 0
replace urban = 1 if closest_urban_dist<=5
replace urban = 1 if school_id==62

save "$Endline_dtRaw/_intermediate files/gps_urban.dta", replace
